package com.zhichat.infrastructure.redis;


import com.zhichat.infrastructure.redis.rediskey.Key;

import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public interface RedisRepository {

    // String
    void set(String key, String value);

    void set(String key, String value, long timeout, TimeUnit unit);

    void set(String key, String value, Duration duration);

    void set(Key key, String value, Object... params);

    <T> void set(Key key, T t, Object... params);

    <T> void set(Key key, List<T> list, Object... params);

    String get(String key);

    <T> T get(String key, Class<T> clazz);

    <T> List<T> getList(String key, Class<T> clazz);

    String get(Key key, Object... params);

    <T> T get(Key key, Class<T> clazz, Object... params);

    <T> List<T> getList(Key key, Class<T> clazz, Object... params);

    long incr(String key);

    long incr(Key key, Object... params);

    void lazyFree(String key);

    void del(String key);

    void del(Key key, Object... params);

    // 设置过期 expire
    void expire(String key, final long timeout, final TimeUnit unit);

    void expire(String key, Duration duration);

    void expire(Key key, Object... params);

    void expireString(String key, final long timeout, final TimeUnit unit);

    void expireString(String key, Duration duration);

    void expireString(Key key, Object... params);

    // List
    <T> void leftPush(String key, T t);

    <T> void leftPushAll(String key, Collection<T> list);

    <T> void leftPush(String key, T t, final long timeout, final TimeUnit unit);

    <T> void leftPush(String key, T t, Duration duration);

    <T> void leftPushAll(String key, Collection<T> list, final long timeout, final TimeUnit unit);

    <T> void leftPushAll(String key, Collection<T> list, Duration duration);

    <T> void leftPush(Key key, T t, boolean isExpire, Object... params);

    <T> void leftPushAll(Key key, Collection<T> list, boolean isExpire, Object... params);

    <T> void leftPush(Key key, T t, Object... params);

    <T> void leftPushAll(Key key, Collection<T> list, Object... params);

    <T> void rightPush(String key, T t);

    <T> void rightPushAll(String key, Collection<T> list);

    <T> void rightPush(String key, T t, final long timeout, final TimeUnit unit);

    <T> void rightPush(String key, T t, Duration duration);

    <T> void rightPushAll(String key, Collection<T> list, final long timeout, final TimeUnit unit);

    <T> void rightPushAll(String key, Collection<T> list, Duration duration);

    <T> void rightPush(Key key, T t, boolean isExpire, Object... params);

    <T> void rightPushAll(Key key, Collection<T> list, boolean isExpire, Object... params);

    <T> void rightPush(Key key, T t, Object... params);

    <T> void rightPushAll(Key key, Collection<T> list, Object... params);

    <T> T leftPop(String key, Class<T> clazz);

    <T> T rightPop(String key, Class<T> clazz);

    <T> T leftPop(Key key, Class<T> clazz, Object... params);

    <T> T rightPop(Key key, Class<T> clazz, Object... params);

    Long size(String key);

    Long size(Key key, Object... params);

    <T> List<T> range(String key, Class<T> clazz);

    <T> List<T> range(String key, Class<T> clazz, int end);

    <T> List<T> range(Key key, Class<T> clazz, Object... params);

    <T> List<T> range(Key key, Class<T> clazz, int end, Object... params);

    <T> void lRemove(String key, T t, int count);

    <T> void lRemove(Key key, T t, int count, Object... params);

    // Set
    <T> void add(String key, Set<T> t);

    <T> void add(String key, Set<T> t, final long timeout, final TimeUnit unit);

    <T> void add(String key,  Set<T> t, Duration duration);

    <T> void add_1(Key key,  Set<T> t, Object... params);

    <T> void add_2(Key key, Set<T> t, Object... params);

    <T> void addAll(String key, Collection<T> list);

    <T> void addAll(String key, Collection<T> list, final long timeout, final TimeUnit unit);

    <T> void addAll(String key, Collection<T> list, Duration duration);

    <T> void addAll(Key key, Collection<T> list, boolean isExpire, Object... params);

    <T> void addAll(Key key, Collection<T> list, Object... params);

    <T> List<T> members(String key, Class<T> clazz);

    <T> List<T> members(Key key, Class<T> clazz, Object... params);

    <T> Boolean isMember(String key, T t);

    <T> Boolean isMember(Key key, T t, Object... params);

    Long card(String key);

    Long card(Key key, Object... params);

    <T> void sRemove(String key, Set<T> t);

    <T> void sRemove(Key key, Set<T> t, Object... params);

    // HashMap
    <T> void setOpsHash(String key, String hashKey, T value);

    <T> T getOpsHash(String key, String hashKey, Class<T> clazz);

    <T> List<T> getListOpsHash(String key, String hashKey, Class<T> clazz);

    void delOpsHash(String key, String hashKey);

    Boolean execLua(String key, String token);
}
